/**
 * Copyright (C), 2013-2019, 中商惠民科技有限公司
 * FileName: 两数之和
 * FileName: 两数之和
 * Author:   Eilen
 * Date:     2019/4/26 17:06
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 **/
package com.algorithm.basic;

import com.google.common.collect.Maps;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * 〈describe〉<br>
 * 〈〉
 *
 * @author Eilen
 * @create 2019/4/26
 * @since 1.0.0
 */
public class 两数之和 {
    public static void main(String[] args) {

        //暴力查找();
        int[] num = {2, 7, 11, 15, -1};
        int tag = 6;
        Map<Integer, Integer> obj = Maps.newHashMap();
        for (int i = 0; i < num.length; i++) {
            if (obj.get(tag - num[i]) != null){
                System.out.println("i=[" + i + "," + obj.get(tag - num[i]) + "]");
            }
            obj.put(num[i], i);
        }

    }

    private static void 暴力查找() {
        int[] num = {2, 7, 11, 15, 1};
        int tag = 16;
        inde:
        for (int i = 0; i < num.length - 1; i++) {
            if (tag > num[i]) {
                for (int j = i + 1; j < num.length; j++) {
                    if (num[j] == tag - num[i]) {
                        System.out.println("i=[" + i + "," + j + "]");
                        break inde;
                    }
                }
            }
        }
    }
}
